﻿using System.IO;
namespace System.Drawing
{
    static public class Ex
    {
        static public Color ReadColor(this BinaryReader br)
        {
            int r, g, b, a;
            r = br.ReadByte();
            g = br.ReadByte();
            b = br.ReadByte();
            a = br.ReadByte();
            return Color.FromArgb(a, r, g, b);
        }
        static public void Write(this BinaryWriter bw, Color color)
        {
            bw.Write(color.R);
            bw.Write(color.G);
            bw.Write(color.B);
            bw.Write(color.A);
        }

        static public Rectangle ReadRectangle(this BinaryReader br)
        {
            int x, y, w, h;
            x = br.ReadInt32();
            y = br.ReadInt32();
            w = br.ReadInt32();
            h = br.ReadInt32();
            return new Rectangle(x, y, w, h);
        }
        static public void Write(this BinaryWriter bw, Rectangle rect)
        {
            bw.Write(rect.X);
            bw.Write(rect.Y);
            bw.Write(rect.Width);
            bw.Write(rect.Height);
        }

        static public Point ReadPoint(this BinaryReader br)
        {
            int x, y;
            x = br.ReadInt32();
            y = br.ReadInt32();
            return new Point(x, y);
        }
        static public void Write(this BinaryWriter bw, Point p)
        {
            bw.Write(p.X);
            bw.Write(p.Y);
        }

        static public Font ReadFont(this BinaryReader br)
        {
            string family = br.ReadString();
            float size = br.ReadSingle();
            FontStyle style = (FontStyle)br.ReadByte();
            return new Font(family, size, style);
        }
        static public void Write(this BinaryWriter bw, Font f)
        {
            bw.Write(f.FontFamily.Name);
            bw.Write(f.Size);
            bw.Write((byte)f.Style);
        }
    }
}

namespace System.Windows.Forms
{

}
